<template>
    <div>
        <span v-for="(i,index) in data" :key="index">{{i}} <br></span>
    </div>
</template>

<script>
export default {
    name: "RanKing.vue",
    data() {
        return {
            data: []
        }
    },
    methods:{
        showModal() {
            this.socket = new WebSocket(`ws:127.0.0.1:8000/ranking/`)
            this.socket.onopen = function (e){
                console.log('连接成功')
            }
            this.socket.onmessage = this.websocketonmessage
        },
        websocketonmessage(e){
            let dataJson = JSON.parse(e.data)
            this.data = dataJson.data
        }
    },
    mounted() {
        this.showModal()
    }
}
</script>

<style scoped>

</style>
